﻿using NHibernate.Tool.hbm2ddl;
using ZenMoney.Core.DataAccess.Config;
using log4net.Config;

namespace ZenMoney.DbCreator
{
    class Program
    {
        private const string ScriptArg = "script";

        static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            var config = NHibernateConfig.Build();
            var schema = new SchemaExport(config);
            var script = false;

            if (args.Length > 0 && ScriptArg.Equals(args[0]))
            {
                script = true;
                schema.SetOutputFile(args[1]);
            }
            
            schema.Drop(script, true);
            schema.Create(script, true);
        }
    }
}
